<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:jsx1="http://matrix.tibco.com/admin/server/services/permissions/messages" 
xmlns:jsx2="http://matrix.tibco.com/admin/server/services/permissions/types" 
exclude-result-prefixes="jsx1 jsx2">

<xsl:output method="xml" omit-xml-declaration="no"/>

	<xsl:template match="/">
		<xsl:apply-templates select="//jsx1:EntityPermissions" />
	</xsl:template>

	<xsl:template match="jsx1:EntityPermissions" >
		<data jsxid="jsxroot">
			<xsl:for-each select="jsx2:userPermission">
				<xsl:if test="jsx2:permission/jsx2:hasOwner = 'true'">
						<record>
							<xsl:attribute name="jsxid">
								<xsl:value-of select="jsx2:userId"/>
							</xsl:attribute>
							<xsl:attribute name="displayName">
								<xsl:value-of select="jsx2:displayName"/>
							</xsl:attribute>
							<xsl:attribute name="userGroupFlag">
								<xsl:value-of select="'user'"/>
							</xsl:attribute>
						</record>
				</xsl:if>
			</xsl:for-each>
			<xsl:for-each select="jsx2:groupPermission">
				<xsl:if test="jsx2:permission/jsx2:hasOwner = 'true'">
						<record>
							<xsl:attribute name="jsxid">
								<xsl:value-of select="jsx2:groupId"/>
							</xsl:attribute>
							<xsl:attribute name="displayName">
								<xsl:value-of select="jsx2:groupName"/>
							</xsl:attribute>
							<xsl:attribute name="userGroupFlag">
								<xsl:value-of select="'group'"/>
							</xsl:attribute>
						</record>
				</xsl:if>
			</xsl:for-each>
		</data>
	</xsl:template>
</xsl:stylesheet>
